package com.example.pong.view;

import android.graphics.Canvas;
import android.graphics.Paint;

public class Display {

	//variables
	int display_height;
	int display_width;
	int ball_x_coord;
	int ball_y_coord;
	int ball_x_vel;
	int ball_y_vel;
	int ball_radius;
	
	public void setup(Canvas canvas, Paint paint){
		
		display_height = canvas.getHeight();
		display_width = canvas.getWidth();
		ball_x_coord = display_width/2;
		ball_y_coord = display_height/2;
		ball_x_vel = 4;
		ball_y_vel = 4;
		ball_radius = 25;
	}
	
	public void update(Canvas canvas, Paint paint){
		//display_width = canvas.getWidth();
		//display_height = canvas.getHeight();
		
		ball_x_coord+=ball_x_vel;
		ball_y_coord+=ball_y_vel;
		
		//right
		if(ball_x_coord+ball_radius>=display_width){
			
			ball_x_vel*=-1;
			
		}
		//left
		if(ball_x_coord-ball_radius<=0){
			
			ball_x_vel*=-1;
			
		}
		//bottom
		if(ball_y_coord+ball_radius>=display_height){
			
			ball_y_vel*=-1;
			
		}
		
		//top
		if(ball_y_coord-ball_radius<=0){
			
			ball_y_vel*=-1;
			
		}
		
	}
	
	public void draw(Canvas canvas, Paint paint){
		canvas.drawRGB(20, 20, 20);
		
		paint.setARGB(150, 255, 255, 255);
		
		canvas.drawCircle(ball_x_coord, ball_y_coord, ball_radius, paint);
		
		paint.setARGB(150, 0, 200, 0);
		
		canvas.drawRect(0, 0, 20, 20, paint);
		
		
		
	}
	
}
